
alter FUNCTION f_getavgprice
(
  @amount decimal(18,2),
  @quantity decimal(18,8)
)  
returns decimal(18,8) 
as
begin
   declare @price decimal(18,8)
   if (isnull(@quantity,0)) > 0
     set @price =  isnull(@amount,0)/(isnull(@quantity,0))
   else
     set @price = 0
  return @price
end


